<?php
declare (strict_types=1);

namespace app\service;


use think\facade\Db;

/**
 * 反馈建议
 * Class FeedbackService
 * @package app\service
 */
class FeedbackService
{

    /**
     * 反馈建议列表
     * @param array $param 参数数组
     * @return array $list
     */
    public static function commentsList($param)
    {
        $model = Db::table('t_feedback')->alias('m');
        if (!empty($param['phone'])) {
            $model->where('m.mobile','like','%'.$param['phone'].'%');
        }
        $res = $model->field('m.id,m.user_id as userId,m.mobile,m.content,m.create_time as createTime')
            ->order('create_time','desc')
            ->paginate(['page' => $param['page'], 'list_rows' => $param['pageSize']])
            ->toArray();
        if (empty($res)) {
            return json_ok((object)array(), 0);
        }

        $list = ['total' => $res['total'],'currentPage'=>$res['current_page'],'lastPage'=>$res['last_page'],'data'=>$res['data']];

        return json_ok($list, 0);

    }


}
